<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
</head>
<body class="timo-layout-page">
<div class="layui-form timo-compile">
    <blockquote class="layui-elem-quote">
        可申请结算金额：<span style="font-weight: bold;color: red" th:text="${maxAmount/100.0}"></span>元。
    </blockquote>
    <form th:action="@{/settleAccount/add}">
        <input type="hidden" name="id" th:if="${settleAccount}" th:value="${settleAccount.id}"/>
        <input type="hidden" name="settleStatus" value="AUDIT"/>
        <input type="hidden" name="mchNo" th:value="${mchNo}"/>
        <input type="hidden" name="payAmount" value="0"/>
        <div class="layui-form-item">
            <label class="layui-form-label">账户属性</label>
            <div class="layui-input-inline">
                <input type="radio" value="PRIVATE" name="accountAttr" checked title="对私"/>
                <input type="radio" value="PUBLIC" name="accountAttr" title="对公"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">账户类型</label>
            <div class="layui-input-inline">
                <input type="radio" value="BANK" name="accountType" lay-verify="required"  checked title="银行账户"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">银行名称</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="accountBankName" lay-verify="required" placeholder="请输入开户行名称" th:value="${settleAccount?.accountBankName}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">网点名称</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="accountBankAddr"  placeholder="请输入网点名称" th:value="${settleAccount?.accountBankAddr}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">账户名称</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="accountName" lay-verify="required" placeholder="请输入账户名称" th:value="${settleAccount?.accountName}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">银行卡号</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="accountNo" placeholder="请输入行卡号" lay-verify="bankno" th:value="${settleAccount?.accountNo}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">结算金额(元)</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" lay-verify="required|number|max" name="settleAmount"  placeholder="请输入结算金额" th:value="${settleAccount?.settleAmount}">
            </div>
        </div>
        <div class="layui-form-item timo-finally">
            <button class="layui-btn" id="submitBtn" lay-submit lay-filter="settleAccount"><i class="fa fa-check-circle"></i>提交申请</button>
        </div>
    </form>
</div>
<script th:replace="/common/template :: script"></script>
<script type="text/javascript">
    layui.use(['element', 'form', 'layer'], function () {
        var $ = layui.jquery;
        var element = layui.element; //加载element模块
        var form = layui.form; //加载form模块
        var layer = layui.layer;

        form.verify({
            max:function (value, item) {
               var maxAmount = [[${maxAmount/100.0}]]
                if(maxAmount < value){
                   return "结算金额不能大于"+maxAmount;mai
                }
                if(value <= 0){
                    return "结算金额必须大于0"
                }
            },
        });
        form.on('submit(settleAccount)', function(data){
            var url = data.form.action;
            var $btn = $("#submitBtn");
            $btn.prop("disabled", true);
            data.field.settleAmount = data.field.settleAmount * 100;
             $.post(url, data.field, function (result) {
                 $btn.removeProp("disabled");
                 if (result.data == null) {
                    parent.layui.customTabChange('/settleAccount/index');
                    parent.layui.element.tabDelete('iframe-tabs', '/settleAccount/add');
                 }
                 $.fn.Messager(result);
             });
            return false;
        });
    });
</script>
</body>
</html>
